#ifndef __H_MOD_GPIO_H__
#define __H_MOD_GPIO_H__

#include "sgw_device.h"
#include "aexgpio.h"

// #ifdef SGWEC_BOARD
// #error "SGWEC_BOARD is defined! This board is not supported."
// #endif

#ifdef SGWEC_BOARD
	#define AEXGPIO_ONBOARD_ADDRESS	"/sys/class/sgwec/sgwec/%s"
	#define AEXGPIOADDREESS 		"/sys/class/sgwec_addr/sgwec_addr"
	#define AEXGPIO_FS				AEXGPIOADDREESS"/%s"
#else
	#define AEXGPIOADDREESS 		"/sys/class/aexgpio/aexgpio27"
	#define AEXGPIO_FS				"/sys/class/aexgpio/aexgpio%x/%s"
	#define RS485_BAUD	9600
#endif

#ifdef SGWEC_BOARD

#define  SGWEC_DEVICE_TYPE		"devicetype"		//输入0
#define  SGWEC_BS_HEART  		"heart"				//输入1
#define  SGWEC_BS_PPS  			"pps"				//输出0
#define  SGWEC_EC_INT 			"ecint"				//输出1
#define  SGWEC_LED_BUS 			"ledbus"			//输出2
#define  SGWEC_LED_ONLINE 		"ledonline"			//输出3
#define  SGWEC_LED_ERROR 		"lederror"			//输出4
#define  SGWEC_CH1_SEL 			"ch1sel"			//输出5
#define  SGWEC_CH2_SEL	 		"ch2sel"			//输出6
#define  SGWEC_RS485_PWRSEL		"pwrsel"			//输出7

	#define  SGWEC_STATUS_BUS			0				//边缘计算的RS485总线是否有效  		
	#define  SGWEC_STATUS_ONLINE		1				//边缘计算时喔斧在线，刚启动时为0，一直连接服务器为1表示在线
	#define  SGWEC_STATUS_ERROR			2				//边缘计算是否有错误发生
	#define  SGWEC_STATUS_CH1RS232		3				//边缘计算串口1通道是否使用RS232，否则使用RS485
	#define  SGWEC_STATUS_CH2RS232		4				//边缘计算串口2通道是否使用RS232，否则使用RS485
	#define  SGWEC_STATUS_MAXNUM		4				//边缘计算最大的数量

#define MAX_UART_NUM	2

int modgpio_waitfor_rs485bus(int busy,int delays);
// int modgpio_rs485bus_write(int fd,char *buf,int len);
// void modgpio_set_modint(unsigned int value);
int modgpio_rs485_write(int fd,char *buf,int len);

#else
#define MAX_UART_NUM	1
#endif

#endif //__H_MOD_GPIO_H__
